<template>
  <div>
    <el-select v-model="value" placeholder="请选择" @change="onChange">
      <el-option
        v-for="item in lang"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
  </div>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  components: {},

  data() {
    return {
      lang: [
        { label: '中文', value: 'zh' },
        { label: '英文', value: 'en' }
      ],
      value: Cookie.get('language') || 'zh'
    }
  },

  created() {},

  methods: {
    onChange() {
      this.$i18n.locale = this.value
      Cookie.set('language', this.value) // 切换多语言
      this.$router.go(0)
    }
  }
}
</script>

<style lang='less' scoped>
</style>
